﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="ResourceList.aspx.cs" Inherits="LizzabethBrownRealEstate.Views.Admin.ResourceList" %>
<%@ Import Namespace="LizzabethBrownRealEstate.Models" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ScriptPlaceHolder" runat="server">
    <script type="text/javascript">
        function setOrder(id) {
            var order = $("#DisplayOrder" + id).val();
            $.post("../Admin.ashx/SetResourceOrder/", { resourceId: id, dispOrder: order });
        }
    </script>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">
    <div class="conentDiv" style="margin-left:25%; margin-top:30px">
        <fieldset style="margin-bottom:20px; width:350px">
            <legend>Buyer/Seller Resources</legend>
            <% LBRDataContext c = new LBRDataContext(); %>
            <table width="100%" style="border-collapse:collapse; margin-bottom:20px;">
            <% foreach (Resource r in c.Resources)
               {
                   if (r.Deleted) continue;%>
               <tr style="cursor:pointer" onmouseover="javascript:this.style.backgroundColor='Silver';" onmouseout="javascript:this.style.backgroundColor='Transparent'">
                    <td><%=Html.TextBox("DisplayOrder" + r.ResourceId.ToString(), r.DisplayOrder, new { style="width:20px", onchange="setOrder('" + r.ResourceId + "')" })%></td>
                    <td>
                        <% if (r.Private)
                           {%>
                            <img src="<%=Url.Content("~/Content/images/lock.png") %>" style="height:15px; width:15px;" />
                            <%} %>
                            <a href='<%= Html.Encode(r.Url) %>' class="resourceListButton" target="_blank" ><%= Html.Encode(r.Caption) %></a>
                    </td>
                    <td><a href='<%= Url.Action("EditResource", new { Controller = "Admin", resourceId = r.ResourceId })%>' class="linktableButton">Edit</a></td>
                    <td><a onclick="javascript:return confirm('Delete this resource?')" href='<%= Url.Action("DeleteResource", new { Controller = "Admin", Id = r.ResourceId })%>' class="linktableButton">Delete</a></td>
               </tr>
            <%} %>
            </table>
        </fieldset>
    </div>
</asp:Content>
